webrtc: Add Sound volume and mute controls support#2213
Draft
thjnk wants to merge 1 commit intogoogle:mainfrom
Draft
webrtc: Add Sound volume and mute controls support#2213thjnk wants to merge 1 commit intogoogle:mainfrom
thjnk wants to merge 1 commit intogoogle:mainfrom
Conversation
5da5ae4 to
3400ea9
Compare
This change implements volume and mute controls for the WebRTC audio backend in Cuttlefish. These controls allow the guest to dynamically adjust playback and capture audio levels via Virtio Sound control messages. - AudioMixer: Apply playback volume scaling during audio stream resampling by modifying the channel mix map. - Implement read/write logic for Virtio audio volume/mute control commands. - Guest Config: Allow enabling of Virtio Sound controls per stream.
Member
|
The three bullet points in the PR description sound like they should be different commits. That would make the PR much easier to review. |
jemoreira
reviewed
Mar 5, 2026
| #include <strings.h> | ||
| #include <unistd.h> | ||
|
|
||
| #include <cstdint> |
Member
There was a problem hiding this comment.
nit: please include <stdint.h> instead
| {SampleRate::Audio_SampleRate_RATE_64000, 64000}, | ||
| }; | ||
|
|
||
| static const auto parse_stream_settings = |
Member
There was a problem hiding this comment.
Looks like this could be a regular function in an anonymous namespace instead of a lambda. Any reason to make it a lambda?
| if (is_muted_by_control) { | ||
| memset(rx_buffer, 0, bytes_read); | ||
| } else if (volume < 1.){ | ||
| static const auto apply_volume = [](auto* data, size_t size, float volume) { |
Member
There was a problem hiding this comment.
This could be a template function instead of a lambda, and you could avoid some repetition by accepting the size in bytes as parameter and dividing by the size of the template parameter. Something like this:
template<typename T>
void apply_volume(T* data, size_bytes, float volume) {
for (T& val: std::span(data, size_bytes / sizeof(T))) {
val *= volume;
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change implements volume and mute controls for the WebRTC audio backend in Cuttlefish. These controls allow the guest to dynamically adjust playback and capture audio levels via Virtio Sound control messages.